package org.hsieh.tr.explore.ui;

import org.eclipse.jface.wizard.Wizard;
import org.hsieh.tr.explore.dbsource.IDatabaseInfo;

public class NewConnectionWizard extends Wizard {

    private NewConnectionWizardPage page = null;
    private IDatabaseInfo databaseInfo;

    public void setDatabaseInfo(IDatabaseInfo databaseInfo) {
	this.databaseInfo = databaseInfo;
    }

    @Override
    public void addPages() {
	page = new NewConnectionWizardPage("New Connection", databaseInfo);
	page.setDescription("Add connection");
	addPage(page);
    }

    @Override
    public boolean performFinish() {
	databaseInfo = page.getDatabaseInfo();
	return databaseInfo != null;
    }

    public IDatabaseInfo getInfo() {
	if (databaseInfo != null)
	    return databaseInfo;
	return page.getDatabaseInfo();
    }
}
